/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package rlpw.lang;

import java.io.*;
import java.util.Collection;

/**
 *
 * @author Ronny
 */
public class Log {
	private static PrintWriter pw; 

	public static void setCodepage(String cp) {
		try {
			pw = new PrintWriter(new OutputStreamWriter(System.out, cp));
		} catch (Exception e) {
			pw = new PrintWriter(System.out);
		}
	}
	
	public static PrintWriter writer() {
		if (pw == null) {
			setCodepage(null);
		}
		return pw;
	}
	
    public static void outln(Object... oa) {
        out(oa);
        out("\n");
    }

    public static void out(Object... oa) {
        for (int i = 0; i < oa.length; i++) {
            writer().print(oa[i]);
        }
        writer().flush();
    }

    public static void outln(Collection<?> list) {
    	boolean skipFirst = true;
        for (Object obj : list) {
        	if (!skipFirst) {
                out(", ");
        	} else {
                skipFirst = false;
        	}
        	out(obj);
        }
        out("\n");
    }
}
